#pragma once

#include "Framework/CommonHead.h"
#include "Widgets/Widget.h"
#include "GridPoistionerWidget.m.h"


//the widget with a positioner
//the positioner will arrange the children's position.
//children must provide width and height
RCLASS()
class WHENGINE_API  RGridPoistionerWidget :public RWidget
{
    ROBJECT
public:          

    //must >0 
    TWidgetAttribute<int32_t> ColumnNum=1;

    float ColumnSpacing=0.f;

    float RowSpacing=0.f;

    virtual void CalculatePresentPositionAndSize() override;
    virtual void CalculateChildrenPresentPositionAndSize() override;
    virtual float CalculateContentWidth() override;
    virtual float CalculateContentHeight() override;


    void ArrangeChildren();

    TDelegate<void> OnChildrenArranged;

protected:
    bool bChildrenArranged=false;
    SVec2 ContentSize;

};